package game;

public class Ship extends Ownable{

	private int[]		rent = {500, 1000, 2000, 4000};
	private int			price = 4000;
	private boolean	doubleRent = false;
	private int			rentAmount;
	private int			shipOwned = 0;

	public Ship(String name){
		setPrice(price);
		this.name = name;
	}

	public void landOnField(Player player){

		super.landOnField(player);
		
		doubleRent = false;
	}

	public int getRent(Player player){
		Ship[] ship = new Ship[4]; 
		ship[0] = (Ship)Board.fields[5];
		ship[1] = (Ship)Board.fields[15];
		ship[2] = (Ship)Board.fields[25];
		ship[3] = (Ship)Board.fields[35];

		shipOwned = 0;

		for(int i=0 ; i<ship.length ; i++){

			if(getOwner() == ship[i].getOwner()){
				shipOwned++;
			}	
		}

		rentAmount = rent[shipOwned-1];

		if(doubleRent == true){
			rentAmount = rentAmount * 2;
		}

		return rentAmount;
	}

	public void setDoubleRent(boolean useDoubleRent){
		doubleRent = useDoubleRent;
	}
}